Stack buffer overflow in prepare_input_tensors() due to unchecked memcpy size#16797
Stack buffer overflow in prepare_input_tensors() due to unchecked memcpy size#16797
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16797
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 8 PendingAs of commit b1dadab with merge base 86b4bea ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
Mitigates a stack buffer overflow risk in prepare_input_tensors() by validating scalar input buffer sizes before copying into stack-allocated variables.
Changes:
- Add strict size checks for
Tag::Int(int64_t),Tag::Double(double), andTag::Bool(bool) inputs prior tomemcpy. - Return
InvalidArgumentwith a descriptive error when the provided scalar buffer size is unexpected.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Can you add a regression test? |
b0e5c6d to
8c8d7dc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8c8d7dc to
c621f13
Compare
c621f13 to
33aa861
Compare
33aa861 to
8090b55
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@mergennachin added one for double. Feel like that should be OK as it's the same logic, and adding tests for bool/int would need new models to |
larryliu0820
left a comment
There was a problem hiding this comment.
Left some non-blocking comments
8090b55 to
801f5a3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
801f5a3 to
e95bc65
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e95bc65 to
1f63405
Compare
1f63405 to
9c75403
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9c75403 to
b1dadab
Compare
Summary
Add size checks for int, double, bool before memcpying. Otherwise the input buffer may be larger than the intended size and overwrite adjacent memory.
Test Plan